#include <bolt.h>
#include "pkt_queue.h"
#include "prot_arp.h"

static int debug_arp = 0;

#define ARP_LOG(fmt, ...) \
  do {                    \
    if (debug_arp)        \
      printf("[%s-%d]"fmt, __func__, __LINE__, ##__VA_ARGS__);\
  }while(0)

bool arp_rx(struct llbuf *ll)
{
  ARP_LOG ("arp received\n");
  
  struct queue_stat *s = get_queue_stat(ll->in);
  if (s)
    s->arp++;
  s = get_queue_stat(ll->out);
  bool ret = pkt_event_send(ll->out, ll);
  if (ret && s != NULL)
    s->arp++;
  return ret;
}    
    
bool arp_tx(struct llbuf *ll)
{
  return false;
}

BOLT(debug_arp, "debug arp on")
{
  debug_arp = 1;
}

BOLT(undebug_arp, "debug arp off")
{
  debug_arp = 0;
}

BOLT_PROFILE(arp, "", arp_profile, desc)
{
  if (debug_arp)
    cmd_load_profile(desc, "debug arp on\n");
}

